clear all
cd "C:\Users\ot3\Documents\TeacherDeseg\Census"

set more off
clear
quietly infix               ///
  int     year       1-4    ///
  byte    datanum    5-6    ///
  double  serial     7-14   ///
  double  hhwt       15-24  ///
  byte    region     25-26  ///
  byte    statefip   27-28  ///
  byte    gq         29-29  ///
  int     pernum     30-33  ///
  double  perwt      34-43  ///
  byte    sex        44-44  ///
  int     age        45-47  ///
  int     birthyr    48-51  ///
  byte    race       52-52  ///
  int     raced      53-55  ///
  byte    hispan     56-56  ///
  int     hispand    57-59  ///
  int     bpl        60-62  ///
  long    bpld       63-67  ///
  byte    educ       68-69  ///
  int     educd      70-72  ///
  byte    empstat    73-73  ///
  byte    empstatd   74-75  ///
  byte    labforce   76-76  ///
  int     occ1950    77-79  ///
  int     ind1950    80-82  ///
  byte    migrate5   83-83  ///
  byte    migrate5d  84-85  ///
  int     migplac5   86-88  ///
  using `"usa_00064.dat"'

replace hhwt      = hhwt      / 100
replace perwt     = perwt     / 100

format serial    %8.0f
format hhwt      %10.2f
format perwt     %10.2f

*Note: Data is already restricted to (1) non-Hispanic blacks and whites (2) employed 
*race dummies
recode race (1=0)(2=1)(else=.), gen(black)
recode race (1=1)(2=0)(else=.), gen(white)

*regions
g bornsouth=inlist(bpl, 1, 5, 12, 13, 22, 28, 37, 45, 47, 48, 51)
replace bornsouth=. if bpl==.
recode bornsouth (0=1)(1=0), gen(bornnorth)

g livesouth=inlist(statefip, 1, 5, 12, 13, 22, 28, 37, 45, 47, 48, 51)  
replace livesouth=. if statefip==.

*gender
recode sex (1=1)(2=0), gen(male)

*education
recode educ (0=0)(1=2)(2=6.5) (3=9)(4=10)(5=11)(6=12)(7=13)(8=14)(9=15)(10=16)(11=18)

*occupations
recode occ1950 (93=1)(nonmiss=0), gen(teacher)
recode occ1950 (0/92 94/99=1)(nonmiss=0), gen(professional)  

*year 
g y1970=year==1970
g teacherX1970=teacher*y1970

keep if livesouth==1 & white==1  & (professional==1 | teacher==1)


save TeachCharWorking, replace






***Table 3***

*Means
use TeachCharWorking
foreach x of varlist bornnorth age male educ  {
qui reg `x' if teacher==1 & year==1960 
est sto `x'T1960
qui reg `x' if teacher==1 & year==1970 
est sto `x'T1970

qui reg `x' if professional==1 & year==1960 
est sto `x'P1960
qui reg `x' if professional==1 & year==1970 
est sto `x'P1970
}
outreg2 [*] using T1,  dec(3)   nor2 noas nose replace 

*Differences
use TeachCharWorking
foreach x of varlist bornnorth age male educ  {
qui reg `x' y1970 if teacher==1, robust
est sto `x'TDiff
qui reg `x' y1970 if professional==1 , robust
est sto `x'PDiff
qui reg `x' y1970 teacher teacherX1970, robust
est sto `x'DD
}
outreg2 [*] using T1,  dec(3)   nor2 nocons replace 















